{% extends 'blog/base.html' %}

{% block main %}
{% if error_msg %}
<p>{{ error_msg }}</p>
{% endif %}
{% for post in post_list %}
<article class="post post-{{ post.pk }}">
    <header class="entry-header">
        <h1 class="entry-title">
            <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
        </h1>
        <div class="entry-meta">
            <span class="post-category"><a href="#">{{ post.category.name }}</a></span>
            <span class="post-date"><a href="#"><time class="entry-date"
                                                      datetime="{{ post.created_time }}">{{ post.created_time }}</time></a></span>
            <span class="post-author"><a href="#">{{ post.author }}</a></span>
            <span class="comments-link"><a href="#">{{ post.comment_set.count }} 评论</a></span>
            <span class="views-count"><a href="#">{{ post.views }} 阅读</a></span>
        </div>
    </header>
    <div class="entry-content clearfix">
        <p>{{ post.excerpt }}...</p>
        <div class="read-more cl-effect-14">
            <a href="{{ post.get_absolute_url }}" class="more-link">继续阅读 <span class="meta-nav">→</span></a>
        </div>
    </div>
</article>
{% empty %}
<div class="no-post">暂时还没有发布文章！</div>
{% endfor %}
<!--简单分页效果-->
{% if is_paginated %}
<div class="pagination">
    <ul>
        {% if first %}
        <li><a href="?page=1">1</a></li>
        {% endif %}
        {% if left %}
            {% if left_has_more %}
            <li>...</li>
            {% endif %}
            {% for page in left %}
            <li><a href="?page={{ page }}">{{ page }}</a></li>
            {% endfor %}
        {% endif %}
        <li class="current" style="color:red">{{ page_obj.number }}</li>
        {% if right %}
            {% for page in right %}
            <li><a href="?page={{ page }}">{{ page }}</a></li>
            {% endfor %}
            {% if right_has_more %}
            <li>...</li>
            {% endif %}
        {% endif %}
        {% if last %}
        <li><a href="?page={{ paginator.num_pages }}">{{ paginator.num_pages }}</a></li>
        {% endif %}
    </ul>
</div>
{% endif %}
{% endblock main %}
